package com.lianzhihui.romeex.ui.wallet;

import android.view.View;
import android.widget.Button;

import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentManager;

import com.lianzhihui.romeex.R;
import com.lianzhihui.romeex.bean.WalletMainBean;
import com.lianzhihui.romeex.ui.MainActivity;
import com.lianzhihui.romeex.ui.base.BaseActivity;
import com.lianzhihui.romeex.widget.MyViewPager;

import java.util.ArrayList;

import butterknife.BindView;
import butterknife.OnClick;

/**
 * Description: 跨链交易界面
 * Author: RAMON
 * CreateDate: 11/13/20 5:12 PM
 * UpdateUser:
 * UpdateDate:
 * UpdateRemark:
 * Version:
 */
public class CrossChainActivity extends BaseActivity {

    @BindView(R.id.bt_in)
    Button bt_in;
    @BindView(R.id.bt_out)
    Button bt_out;
    @BindView(R.id.viewpager)
    MyViewPager viewpager;

    WalletMainBean.CoinBean coin;
    public ArrayList<Fragment> fragmentList;

    @Override
    protected int getLayoutId() {
        return R.layout.activity_cross_chain_layout;
    }

    @Override
    protected void initView() {
        setTitle("USDT跨链");
        bt_in.setSelected(true);
        coin = (WalletMainBean.CoinBean) getIntent().getSerializableExtra("coin");
        if (coin == null) {
            return;
        }
        initViewPager();
    }

    private void initViewPager() {

        fragmentList = new ArrayList<>();
        fragmentList.add(ShouqianFragment.newInstance(coin));
        fragmentList.add(new ZhuanZhangFragment());

        FragmentManager fragmentManager = getSupportFragmentManager();
        MainActivity.MyFragmentAdapter adapter = new MainActivity.MyFragmentAdapter(fragmentManager, fragmentList);
        viewpager.setScrollable(false);
        viewpager.setOffscreenPageLimit(2);
        viewpager.setAdapter(adapter);
    }

    @Override
    protected void initData() {

    }

    @OnClick({R.id.bt_out, R.id.bt_in})
    public void onClick(View view) {
        switch (view.getId()) {
            case R.id.bt_in:

                bt_in.setSelected(true);
                bt_in.setTextColor(getResources().getColor(R.color.white));
                bt_out.setSelected(false);
                bt_out.setTextColor(getResources().getColor(R.color.theme_color));
                viewpager.setCurrentItem(0);
                break;
            case R.id.bt_out:

                bt_in.setSelected(false);
                bt_in.setTextColor(getResources().getColor(R.color.theme_color));
                bt_out.setSelected(true);
                bt_out.setTextColor(getResources().getColor(R.color.white));
                viewpager.setCurrentItem(1);
                break;
        }
    }

}
